// Learn TypeScript:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export  class MoveAnimCtrl extends cc.Component {

   
   @property(cc.Animation)
   target:cc.Animation=null;

   //节点数组
   @property([cc.Node])
   nodeArray:Array<cc.Node>=[];
  
    // LIFE-CYCLE CALLBACKS:

   protected onLoad () {

   }
private onRegisterEvent(){
    for(let i=0;i<this.nodeArray.length;i++){

        this.nodeArray[i].on(cc.Node.EventType.TOUCH_END,this.onPlayAnimation.bind(this));
    }
}
    private onPlayAnimation(event){

        this.target.stop();

        switch(event.target._name){
            case "Linear":
            this.target.play("linear");
            break;
        case "CaseIn_Expo":
            this.target.play("caseIn-expo");
            break;
        case "CaseOut_Expo":
            this.target.play("caseOut-expo");
            break;
        case "CaseInOut_Expo":
            this.target.play("caseInOut-expo");
            break;
        case "Back_Forward":
            this.target.play("back-forward");
            break;
        }
    }
    // update (dt) {}
}
